;; Mode: LISP; Syntax: Common-lisp; Package: aklemme
;; Names: Ardell Klemme, Bruce Ho, Jimmy Cumming         Date: 11/05/12
;; Course: ICS 313   Assignment: 6
;; File: object-location-path.lisp

; AK: set default location to bridge              
(defparameter *location* 'bridge)
; AK: defines global symbol for objects, default to '()                                    
(defparameter *objects* '())
; AK: defines global symbol for object-locations, default to '()
(defparameter *object-locations* '())
; AK: defines global symbol for nodes, default to '()
(defparameter *nodes* '())
; AK: defines global symbol for edges, default to '()
(defparameter *edges* '())

;;;=========================Locations=============================;;;

;AK: New location; Bridge
(new-location bridge you are on the bridge.
             you see several control panels along the walls.
             there are several chairs in the room.
             one chair is in the center of the room.
             two other chairs are between the main chair and a viewscreen.)

;JC: New location; Deck-13
(new-location deck-13 you are on deck-13.
	      there isn't much to look at here. The walls are gray and bland. 
	      There's a well lit hallway and several doors leading to other parts of the ship.)
;JC: New location: Lounge
(new-location lounge you are on the lounge. 
	      There are several couches and the lighting is much less harsh. 
	      The bar is well stocked.)
;JC: New location: Shuttle-bay
(new-location shuttle-bay you are in the shuttle-bay.
	      the nearest shuttle is undergoing maintenance and all of the access panels have been removed.)
;JC: New Location Cargo-bay
(new-location cargo-bay you are in the cargo-bay.
	      The cargo bay is packed full of crates. One of the nearby crates marked explosives seems to have burst open. 
	      watch your step!)
;JC: New location Deck-23
(new-location deck-23 you are on deck-23.
	      the emergency lights have turned on and the normal lighting appears to have gone off. 
	      You can hear the emergency generators kicking in.)
;JC: New location; Torpedo-bay
(new-location torpedo-bay you are in the torpedo-bay. 
	      There are rows upon rows of torpedoes here ready to launch.
	      One torpedo lies in pieces on a nearby cart. 
	      it seems the engineers were interrupted while reassembling it.)
;JC: New location; Armory
(new-location armory you are in the armory.
	      You notice that someone has been here recently and has left the rifle locker open.
	      This is against protocol so they were obviously in some sort of a hurry.)
;JC: New location: Transporter-room
(new-location transporter-room You are in the transporter room. 
	      There is a console with a big button and a pad in the middle of the room.
	      You have no idea if the transporter even works.)
;AK: New location; Main-engineering
(new-location main-engineering you are in main-engineering.
             you see the warp core in the center of the room.
             there are several consoles around the room with schematics 
             and status displays.
             you see a flashing red light next to the warp core breach
             warning.
	     Lastly you see a workstation where you can \"integrate\" two components together to make a metaphasic-transinducer-array.)
              

;;;===========================Paths===============================;;;

; AK: New path from Bridge to Engineering & back
(new-path bridge deck-13  down turbolift up)
(new-path deck-13 lounge fore sliding-door aft)
(new-path deck-13 shuttle-bay starboard airlock port)
(new-path deck-13 cargo-bay port cargo-door starboard)
(new-path deck-13 deck-23 down turbolift up)
(new-path deck-23 torpedo-bay fore blast-resistant-door aft)
(new-path deck-23 main-engineering aft severely-damaged-door fore)
(new-path deck-23 transporter-room starboard high-tech-door port)
(new-path deck-23 armory port blast-resistant-door starboard)

;;;=========================Objects===============================;;;

; AK: New object hydro-spanner added to engineering
;(new-object hydro-spanner main-engineering)
(new-object plasma-conduit transporter-room)
(new-object positronic-relay shuttle-bay)
(new-object inverter-casing cargo-bay)
(new-object stable-powercell armory)
(new-object plasma-rifle armory)
(new-object bottle-of-romulan-ale lounge)
(new-object anti-matter-warhead torpedo-bay)
(new-object sexy-shades bridge)


;;;=====================Helper Functions==========================;;;


;; jc We need the *nodes* we can probably make do with this otherwise I added the default from assignment5:
; ;(defparameter *nodes* (()))
; ; AK: defines nodes that contain locations and descriptions
; (defparameter *nodes* '((living-room (you are in the living-room.
;            a wizard is snoring loudly on the couch.))
;                         (garden (you are in a beautiful garden.
;                             there is a well in front of you.))
;                         (attic (you are in the attic.
;                             there is a giant welding torch in the corner.))))
; 
; 
; ; AK: defines list of edges at each location and their direction/path
; (defparameter *edges* '((living-room (garden west door)
;                                      (attic upstairs ladder))
;                         (garden (living-room east door)
;                                      ; AK: adds edge to new location
;                                      (armory underground passage-way))
;                         (attic (living-room downstairs ladder))
;                         ; AK: this is the new location with edge back
;                         (armory (garden up passage-way))))
; 
; ; AK: defines all objects in the game.
; (defparameter *objects* '(whiskey bucket frog chain scabbard blade hilt
;                           crossguard stone-of-power))
; 
; ; AK: define multi-part object - the sword of omens here.
; (defparameter *multi-part-obj* '(sword-of-omens
;                                  (blade hilt crossguard stone-of-power)))
; 
; ; AK: defines all object location associations.
; (defparameter *object-locations* '((whiskey living-room)
;                                    (bucket living-room)
;                                    (chain garden)
;                                    (frog garden)
;                                    (scabbard armory)
;                                    ; AK: place sword-of-omen pieces in world
;                                    (blade attic)
;                                    (hilt living-room)
;                                    (crossguard armory)
;                                    (stone-of-power garden)))



; AK: describes description associated with location parameter
(defun describe-location (location nodes)
   (cadr (assoc location nodes)))
   
; AK: describes path and direction for each edge
(defun describe-path (edge)
 `(there is a ,(caddr edge) going ,(cadr edge) from here.))

; AK: describes paths available from this location
(defun describe-paths (location edges)
 (apply #'append (mapcar #'describe-path (cdr (assoc location edges)))))
 
; AK: shows only objects at location
(defun objects-at (loc objs obj-loc)
  (labels ((is-at (obj)
             (eq (cadr (assoc obj obj-loc)) loc)))
      (remove-if-not #'is-at objs)))

; AK: describes objects in current location  
(defun describe-objects (loc objs obj-loc)
  (labels ((describe-obj (obj)
               `(you see a ,obj on the floor.)))
     (apply #'append (mapcar #'describe-obj (objects-at loc objs obj-loc)))))